package 比屋作业.day14;

public class D14_1 {
    public static void main(String[] args) {
        Circle circle1=new Circle(4);
        Circle circle2=new Circle(5);
        circle1.printInof();
        circle2.printInof();
        System.out.println(circle1.equals(circle2));
        Ratangle ratangle1=new Ratangle(4,5);
        Ratangle ratangle2=new Ratangle(5,6);
        ratangle1.printInof();
        ratangle2.printInof();
        System.out.println(ratangle1.equals(ratangle2));
    }
}
abstract class shape{
    public abstract void printInof();
}
class Circle extends shape{
    private double radiu;
    public Circle(double radiu){
        this.radiu=radiu;
    }
    @Override
    public void printInof() {
     StringBuilder sb=new StringBuilder("圆形的半径是：");
     sb.append(radiu);
        System.out.println(sb);
    }

    @Override
    public boolean equals(Object obj) {
        Circle circle=(Circle) obj;
        return this.radiu== circle.radiu;
    }
}
class Ratangle extends shape{
    private double chang;
    private double kuan;
    public Ratangle(double chang, double kuan){
        this.chang=chang;
        this.kuan=kuan;
    }
    public double getKuan(){
        return kuan ;
    }

    public double getChang() {
        return chang;
    }

    @Override
    public void printInof() {
        StringBuilder stringBuilder=new StringBuilder("长为：");
        stringBuilder.append(chang);
        stringBuilder.append("，宽为：");
        stringBuilder.append(kuan);
        System.out.println(stringBuilder);
    }

    @Override
    public boolean equals(Object obj) {
        Ratangle ratangle=(Ratangle) obj;
        return this.chang==ratangle.chang&&this.kuan==ratangle.kuan;
    }
}